#+TITLE: Loading Small Packages
#+AUTHOR:Joshua Branson
#+LATEX_HEADER: \usepackage{lmodern}
#+LATEX_HEADER: \usepackage[QX]{fontenc}

This file just loads in tiny packages that don't really need to be in separate files.
* lexical binding
:PROPERTIES:
:ID:       15a3435c-73db-412c-adcb-58483e9cffb5
:END:
#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding: t -*-
#+END_SRC
* Helpful Emacs libraries
:PROPERTIES:
:ID:       f4704100-48f4-4088-a161-2be8377bed87
:END:
** s
:PROPERTIES:
:ID:       1f030f34-1f05-44f8-945d-8ceb21c7505d
:END:
#+BEGIN_SRC emacs-lisp
  (use-package s)
#+END_SRC
** dash
:PROPERTIES:
:ID:       58f64057-1aea-4054-ae8f-fecde6178f5b
:END:
#+BEGIN_SRC emacs-lisp
(use-package dash)
#+END_SRC

** alert
:PROPERTIES:
:ID:       fba16a4d-42f0-4f36-95b0-214fc73c2e85
:END:
#+BEGIN_SRC emacs-lisp
(use-package alert :defer t)
#+END_SRC
** async
:PROPERTIES:
:ID:       9d7b0209-dda3-4155-aef7-0e3dbdc5398e
:END:

Async uses another Emacs to async-ously execute emacs lisp code.

#+BEGIN_SRC emacs-lisp
(use-package async
  :defer t
  ;;:config
  ;; enable async compilation of melpa packages
  ;;(async-bytecomp-package-mode 1)
)
#+END_SRC

Here is an example of what you can do with async.
#+BEGIN_SRC emacs-lisp :tangle no
(async-start
   ;; What to do in the child process
   (lambda ()
     (message "This is a test")
     (sleep-for 3)
     222)

   ;; What to do when it finishes
   (lambda (result)
     (message "Async process done, result should be 222: %s" result)))
#+END_SRC
** namespace
** f
   :PROPERTIES:
   :ID:       05d87555-d6c3-4bd9-9b2e-158a1deff0f7
   :END:
#+BEGIN_SRC emacs-lisp
(use-package f :defer t)
;;(require 'f)
#+END_SRC
* Parenthesis
** Show matching parens
:PROPERTIES:
:ID:       46d36ead-f555-4a6f-abcf-201ece93a489
:END:
 With point over one paren, Emacs will highlight both parens.

 #+BEGIN_SRC emacs-lisp
 (add-hook 'prog-mode-hook 'show-paren-mode)
 #+END_SRC
** Electric pair mode
:PROPERTIES:
:ID:       1672d05c-1f83-48b0-a5d8-c9f838c1a954
:END:

 When you type an open parenthsis, electric pair mode types the second one for you, leaving point between them.

  #+BEGIN_SRC emacs-lisp
  (add-hook 'prog-mode-hook 'electric-pair-mode)
  ;;(electric-pair-mode t)
 #+END_SRC
** rainbow delimiters
:PROPERTIES:
:ID:       5671bd7d-efd1-460f-b8e2-c09fd812313f
:END:

Each pair of parenthesis-es will have different colors.  This can aid in discovering which parenthesis matches which parenthesis.

#+BEGIN_SRC emacs-lisp
  (use-package rainbow-delimiters  :defer t)
  (dolist (hook '(js2-mode-hook js-mode-hook json-mode-hook emacs-lisp-mode-hook scheme-mode-hook))
    (add-hook hook 'rainbow-delimiters-mode))
#+END_SRC
* Emacs's default query-replace sucks.  Let's use anzu!
:PROPERTIES:
:ID:       b93b547a-2b97-4896-af4b-e6f4c783457e
:END:
Anzu is amazing!  It highlight the words that you wish to replace.

I have also bound the command to run the command via "Q" in vim normal-mode.

#+BEGIN_SRC emacs-lisp
  (use-package anzu
    :config (global-anzu-mode 1)
    :diminish (anzu-mode))
#+END_SRC

* enable flyspell for all program modes.
:PROPERTIES:
:ID:       bca2e633-d8eb-4d29-a059-8f2d6f18eb57
:END:

This will highlight words that are misspelled.  Flyspell-prog-mode will do this for programming, flyspell-mode is for text files.

[[~/.config/emacs/images/flyspell.png]]

Also flyspell binds C-c $ to flyspell fix word before point.  BUT I used to prefer that to be bound to endless/ispell-word-then-abbrev.

#+BEGIN_SRC emacs-lisp
  (add-hook 'prog-mode-hook (lambda ()
                              (flyspell-prog-mode)))
                              ;;(unbind-key (kbd "C-c $") flyspell-mode-map)
                              ;;(global-set-key (kbd "C-c $") #'endless/ispell-word-then-abbrev))

  ;; enable flyspell mode for all of my text modes.  This will enable flyspell to underline misspelled words.
  (add-hook 'text-mode-hook (lambda ()
                              (flyspell-mode)))

  ;;(unbind-key (kbd "C-c $") flyspell-mode-map)
  ;;(global-set-key (kbd "C-c $") #'endless/ispell-word-then-abbrev))
#+END_SRC

Oddly enough web-mode doesn't seem to support flyspell.

* Projectile
:PROPERTIES:
:ID:       24fce274-7aa4-4de9-b2a0-f2c7b4783b2e
:END:
Projectile is a package that attempts to make it easier for Emacs to do various commands that are specific to your repositories.

#+BEGIN_SRC emacs-lisp
  (use-package projectile
    :config
    ;;(use-package helm)
    ;;(use-package helm-projectile)
    (setq projectile-enable-caching t
          projectile-completion-system 'helm)
    (helm-projectile-on)
    :diminish (projectile-mode)
    :hook (prog-mode . projectile-global-mode)
    :bind-keymap
    ("C-c p" . projectile-command-map)
    :defer t)

  #+END_SRC

Projectile also supports setting projectile-project-compilation-dir via a [[info:emacs#Directory%20Variables][.dir-locals.el]] file.  This file is a specific Emacs file that sets per-buffer variables for any files inside that directory.  I use this for making the projectile-compile-project (C-c p c p) command to work in my ~/programming/c/ directory.  You can view that [[file:~/programming/c/.dir-locals.el::((nil%20.%20((projectile-project-compilation-dir%20.%20"c/"))))][file]] here.

Alternatively, you could learn to use GNU autotools, specifically automake, which would probably make your life a little easier.

* auth-source
:PROPERTIES:
:ID:       90ce5dc0-d72b-4263-a0c6-14cc88a5838c
:END:
If I have a .authinfo, .authinfo.gpg, or .netrc, then load auth-source.el

How to use auth-source and gpg to encrypt files.  Also how to transfer keys between machines.
https://www.masteringemacs.org/article/keeping-secrets-in-emacs-gnupg-auth-sources

Auth-source.el, lets you save your various logins and password for different servers in one file.  For someone like me, who has never gotten ssh keys to work (it always ALWAYS ANNOYING prompts me for a password), I just have my information stored in .authinfo.gpg, which is an encrypted file.

Ensure that you have f.el
#+BEGIN_SRC emacs-lisp
(use-package f  :defer t)
;;(require 'f)
#+END_SRC


According to Mastering Emacs blog...gpg is an outdated (ancient) version of gpg.  gpg2 is newer and should be used!

gpg is the version more suited for servers.  Gpg2 is the version more suited for desktop use.   Here is a [[http://superuser.com/questions/655246/are-gnupg-1-and-gnupg-2-compatible-with-each-other/655250#655250][stackoverflow answer.]] describing the difference between gpg and gpg2.

At the moment I dual boot Parabola GNU/Linux and GuixSD.  At some point, I want to migrate over to use GuixSD, but Parabola has some features, services, and packages that Guix lacks.  So until that time, I'll have to use both.  BUT the good news is that I can tell Emacs which gpg binary to use based upon my host name.  If my host name is "antelope" the default GuixSD host-name then make the egp-gpg-program be gpg.  If it's parabola, make it "gpg2". "parabola" uses gpg2.  GuixSD needs to use gpg.  gpg2 is the newer version.  You should use gpg2 if you can.

#+BEGIN_SRC emacs-lisp
  (setq epg-gpg-program "gpg2")
#+END_SRC

#+RESULTS:
: gpg2


#+BEGIN_SRC emacs-lisp :tangle no
  (when (and (display-graphic-p) (f-file? "~/.authinfo.gpg"))
    ;; only use the encrypted file.
    (setq auth-sources '("~/.authinfo.gpg")))
#+END_SRC

Don't let Emacs use the default gpg agent pin.  Instead make Emacs prompt you for a password.

I'm not sure what this is?
#+BEGIN_SRC emacs-lisp
;;(setenv "GPG_AGENT_INFO" nil)
#+END_SRC
* recent
:PROPERTIES:
:ID:       0a6a1dca-1f12-4b1d-afd3-70d427d695ec
:END:
#+BEGIN_SRC emacs-lisp
  (defun my-recentf-startup ()
  "My configuration for recentf."
  (recentf-mode 1)
  (setq recentf-max-saved-items 1000
        recentf-exclude '("/tmp/"
              "^.*autoloads.*$"
              "^.*TAGS.*$"
              "^.*COMMIT.*$"
              "^.*pacnew.*$"
                          ;; in case I ever want to exclude shh files, I can add this next line.
                          ;;  "/ssh:"
              ))

  (add-to-list 'recentf-keep "^.*php$//")
  (recentf-auto-cleanup)
  ;;every 5 minutes I should try to save the list of recent files.
;; if emacs quits abrubtly, then those files will be lost.
  (run-at-time nil (* 5 60) 'recentf-save-list))
  (add-hook 'after-init-hook 'my-recentf-startup)
#+END_SRC
* ag
:PROPERTIES:
:ID:       6f4c9bad-cf74-43b6-b87c-39e781ae0961
:END:
#+BEGIN_SRC emacs-lisp
(setq-default grep-highlight-matches t
              grep-scroll-output t)
;; ag is the silver searcher.  It lets you search for stuff crazy fast
(when (executable-find "ag")
  (use-package ag :defer t)
  (use-package helm-ag :defer t)
  (use-package wgrep-ag :defer t )
  (setq-default ag-highlight-search t))
#+END_SRC
* minor modes
** yasnippet
:PROPERTIES:
:ID:       20eb3ae4-97e1-4356-a54f-78af87b4647b
:END:

#+BEGIN_SRC emacs-lisp
  (use-package yasnippet
    ;; (define-key company-mode-map (kbd "TAB") #'yas-expand)
    ;; (define-key company-mode-map (kbd "<tab>") #'yas-expand)
    ;; don't use yas-global-mode.  I don't need yas in eww-mode
    ;;:hook (prog-mode text-mode)
    :config
    ;; get some of the yasnippet snippets
    (yas-global-mode)
    ;;(use-package yasnippet-snippets)
    )
  #+END_SRC

If I modify a buffer via a yasnippet with a back-ticks like ~`SOME ELISP CODE `~, then yasnippet will issue a warning.  Let's tell yasnippet to ignore that.

#+BEGIN_SRC emacs-lisp
  (with-eval-after-load 'warnings
    (add-to-list 'warning-suppress-types '(yasnippet backquote-change)))
#+END_SRC

#+BEGIN_SRC emacs-lisp
    ;; Assuming the Guix checkout is in ~/src/guix.
    (with-eval-after-load 'yasnippet
      (add-to-list 'yas-snippet-dirs "/home/joshua/prog/gnu/guix/guix-src/etc/snippets")
      (add-to-list 'yas-snippet-dirs "/home/joshua/.config/emacs/auto-insert-directory"))

#+END_SRC

*** COMMENT using yasnippet with evil-mode

This advises yasnippet, so that when I expand a snippet, I change to insert state and leave in insert state.

But it is probably not necessary.  When I am about to expand a snippet, I am typically in insert state anyway.
#+BEGIN_SRC emacs-lisp :tangle no
  (when evil-mode
    (advice-add 'evil-insert-state :before 'yas-expand)
    (advice-add 'evil-insert-state :after 'yas-expand))

#+END_SRC
** geiser
   :PROPERTIES:
   :ID:       08c8e25c-6513-4ad5-a598-a1b40db2040b
   :END:

Geiser is already installed.  I just want to make sure that Geiser gets info from the guix source files.

Getting the "perfect setup" setup.
#+BEGIN_SRC emacs-lisp
  (with-eval-after-load 'geiser-guile
    (add-to-list 'geiser-guile-load-path "/home/joshua/prog/gnu/guix/guix-src"))
#+END_SRC

#+BEGIN_SRC scheme
  (load-file "/home/joshua/prog/gnu/guix/guix-src/etc/copyright.el")
#+END_SRC

To do auto updating of copyright.
#+BEGIN_SRC scheme
  (setq copyright-names-regexp
        (format "%s <%s>" user-full-name user-mail-address))
  (add-hook 'after-save-hook 'copyright-update)
#+END_SRC

** avy-mode
:PROPERTIES:
:ID:       b0fe4e52-38b9-4846-b737-7ac2b025527f
:END:
 I use avy mode for avy jump to char, which is a little nicer than ace-jump mode, but not by much.

 #+BEGIN_SRC emacs-lisp
(use-package avy
  :defer t
  :config
  (setq avybackground t
   avy-highlight-first t)
  ;; https://github.com/abo-abo/avy
  ;; What does that do?
  (setq avy-keys (number-sequence ?e ?t )))
 #+END_SRC

** visual line mode
:PROPERTIES:
:ID:       c65ee7c6-61e4-46a5-b09f-70ff12cc14eb
:END:

Filling is what one does to insert actual or invisible newlines at a really long sentence to make a paragraph.
For example:

This is a really long sentence, but when you call fill paragraph on it, with point inside it, it might look something like this:

This is a really long sentence,
but when you call fill paragraph
on it, with point inside it, it
might look something like this:

Emacs by default does not automatically call fill paragraph for you.  Instead, it shows your visual characters to show you that your text is too big for the buffer.   It looks like this:

#+BEGIN_SRC org
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi bibendum elit sodales ↵
  sapien porta, ut aliquet orci volutpat. Nulla non est vel ante pulvinar elementum eu ac  ↵
  neque. Aliquam dapibus ipsum vulputate varius faucibus. Proin finibus rhoncus diam in ↵
  interdum. Nullam a elit auctor felis eleifend rutrum. Fusce odio quam, vehicula vitae ↵
  ullamcorper sit amet, consectetur ac elit. Nunc at rutrum risus, quis ullamcorper risus. ↵
#+END_SRC

Global visual line mode, will automatically remove those arrows and make it looks like this:

#+BEGIN_SRC org
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi bibendum elit sodales
  sapien porta, ut aliquet orci volutpat. Nulla non est vel ante pulvinar elementum eu ac
  neque. Aliquam dapibus ipsum vulputate varius faucibus. Proin finibus rhoncus diam in
  interdum. Nullam a elit auctor felis eleifend rutrum. Fusce odio quam, vehicula vitae
  ullamcorper sit amet, consectetur ac elit. Nunc at rutrum risus, quis ullamcorper risus.
#+END_SRC

#+BEGIN_SRC emacs-lisp
  (add-hook 'after-init-hook 'global-visual-line-mode)
  (global-set-key (kbd "C-c q") #'fill-paragraph)
#+END_SRC
** aggressive indent
:PROPERTIES:
:ID:       97237f5e-8877-4168-8d77-264c1e46cd13
:END:

Aggressive indent attempts to aggressively indent you code after you
change various aspects of it.  It doesn't work well with org-mode and
web-mode.  And it seems to aggressively re-indent my entire scheme
buffers.

#+BEGIN_SRC emacs-lisp
  (use-package aggressive-indent
    :defer t
    :config
    (add-to-list 'aggressive-indent-excluded-modes 'makefile-gmake-mode)
    (add-to-list 'aggressive-indent-excluded-modes 'makefile-mode)
    (add-to-list 'aggressive-indent-excluded-modes 'web-mode)
    (add-to-list 'aggressive-indent-excluded-modes 'org-mode)
    (add-to-list 'aggressive-indent-excluded-modes 'clojure-mode-hook)
    (add-to-list 'aggressive-indent-excluded-modes 'emacs-lisp-mode-hook)
    (add-to-list 'aggressive-indent-excluded-modes 'common-lisp-mode-hook)
    (add-to-list 'aggressive-indent-excluded-modes 'scheme-mode-hook)
    (add-to-list 'aggressive-indent-excluded-modes 'lisp-mode-hook)
   ;; :hook (message-mode . aggressive-indent-mode)

   )
#+END_SRC
** guix devel mode

This mode turns on proper indentation for scheme code for use by Guix System.

#+BEGIN_SRC sh :results output :exports both
 (add-hook 'scheme-mode-hook 'guix-devel-mode)
#+END_SRC
** aggressive fill paragraphs
   :PROPERTIES:
   :ID:       d98de97e-3e06-4abe-86f9-4baed8d5d9cf
   :END:

#+BEGIN_SRC emacs-lisp
  (use-package aggressive-fill-paragraph
    :config
    (afp-setup-recommended-hooks)
    (add-hook 'mail-mode-hook #'aggressive-fill-paragraph-mode)
    (add-hook 'message-mode-hook #'aggressive-fill-paragraph-mode)
    ;;(add-hook 'scheme-mode-hook #'aggressive-fill-paragraph-mode)
    ;;(add-hook 'org-mode-hook    #'aggressive-fill-paragraph-mode)
    ;;(add-to-list 'afp-fill-comments-only-mode-list 'scheme-mode)
    )
#+END_SRC
* various major modes
** json-mode
:PROPERTIES:
:ID:       ef230b69-aef4-41d2-b91c-db2381d88142
:END:

#+BEGIN_SRC emacs-lisp
  (use-package json-mode
    :mode
    ("\\.json\\'" . json-mode))
#+END_SRC

** eshell
:PROPERTIES:
:ID:       4f6ec06a-4f1b-44c6-ac5f-b0804649b90b
:END:

First, Emacs doesn't handle less well, so use cat instead for the shell pager:
#+BEGIN_SRC emacs-lisp
;;(setenv "PAGER" "cat")
#+END_SRC

using ac-source-filename IS super useful
it is only activated if you start to type a file like
 "./", "../", or "~/" but then it's awesome!

#+BEGIN_SRC emacs-lisp
(add-hook 'eshell-mode-hook '(lambda ()
                              (setq shell-aliases-file "~/.config/emacs/alias")))
#+END_SRC
*** fish completion
:PROPERTIES:
:ID:       c219465d-c786-4e14-8990-12201acfd05d
:END:
TODO make this lazy loading
#+BEGIN_SRC emacs-lisp
  (when (and (executable-find "fish")
             (require 'fish-completion nil t))
    (progn
      (add-hook 'eshell-mode-hook 'fish-completion-mode)))
#+END_SRC
** markdown
:PROPERTIES:
:ID:       4f12892e-8b3b-4b1e-b606-0be712f28f5b
:END:
#+BEGIN_SRC emacs-lisp
  (defun my/set-fill-column-80 ()
    "set the fill column to 80"
    (interactive)
    (auto-fill-mode)
    (setq fill-column 80)
    (set-fill-column 80))

  (use-package markdown-mode
    :defer t
    :commands (markdown-mode gfm-mode)
    :mode (("README\\.md\\'" . gfm-mode)
           ("\\.md\\'" . markdown-mode)
           ("\\.mdwn\\'" . markdown-mode)
           ("\\.markdown\\'" . markdown-mode))
    :init (setq markdown-command "multimarkdown"))

  ;; writing GNU/Hurd wiki edits should only have 80 characters
  ;; per column
  (add-hook 'markdown-mode-hook 'my/set-fill-column-80)
#+END_SRC
** c-mode
  :PROPERTIES:
  :ID:       55ba0f1d-1032-412c-a974-2a2c81990858
  :END:
Open .defs files in c-mode.  These are found in the Hurd source code.
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.defs?\\'" . c-mode))
#+END_SRC

** nov mode
:PROPERTIES:
:ID:       0eed7f37-c991-4795-ba26-ba477afdaab2
:END:

This mode lets you read epub documents inside Emacs.  How cool is that?

#+BEGIN_SRC emacs-lisp
  (use-package nov
    :mode ("\\.epub\\'" . nov-mode))
#+END_SRC

** nginx
:PROPERTIES:
:ID:       304a2600-ea37-461f-a607-09e2d9a27561
:END:

#+BEGIN_SRC emacs-lisp
  (use-package nginx-mode :defer t)
  (add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode))
#+END_SRC
** lua
:PROPERTIES:
:ID:       d9846cc0-b907-4703-98e9-1fc189a6dca5
:END:
#+BEGIN_SRC emacs-lisp
(use-package lua-mode
    :mode ("\\.lua\\'" . lua-mode))
#+END_SRC
** git
*** magit
:PROPERTIES:
:ID:       8e5f5d56-7cf6-41b1-bc62-24f0e6cd488f
:END:

Apparently you can use this to set make magit-status open in a full frame.
#+BEGIN_SRC emacs-lisp
  (use-package magit :defer t
  :init
  (setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1)
  :config
  (setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1))
#+END_SRC

In ediff mode, open up org-files in showall.  That way you don't have to tab open things.
#+BEGIN_SRC emacs-lisp
(add-hook 'ediff-prepare-buffer-hook #'outline-show-all)
#+END_SRC

When we start working on git-backed files, use git-wip if available.  This auto saves git files in a wip in progress branch on the current progress.  You can learn more here: https://magit.vc/manual/2.1/magit/Wip-Modes.html

#+BEGIN_SRC emacs-lisp :tangle no
(after-load 'magit
   ;;(global-magit-wip-save-mode)
  (setq magit-display-buffer-functions 'magit-display-buffer-fullframe-status-v1))
#+END_SRC

#+BEGIN_SRC emacs-lisp
(setq-default
 magit-save-some-buffers nil
 magit-diff-refine-hunk t)
#+END_SRC

If a command takes longer than 5 seconds, pop up the process buffer.
#+BEGIN_SRC emacs-lisp
 (setq magit-process-popup-time 15)
#+END_SRC




**** turning off scroll bar mode in ediff
:PROPERTIES:
:ID:       0ff128eb-1293-4e8c-9480-d3289880d7d2
:END:
I also don't really need scroll-bar-mode enabled with ediff, but I can't get scroll-bar-mode to turn back on.

#+BEGIN_SRC emacs-lisp
  (defun my/turn-off-scroll-bars ()
    "My specific function for turning off my vertical scroll-bars."
    (set-scroll-bar-mode nil))

  (defun my/turn-off-scroll-bars ()
    "My specific function for turning on on scoll-bars."
    (set-scroll-bar-mode t))
#+END_SRC

TODO  I can probably remove one or two of these hooks.
#+BEGIN_SRC emacs-lisp
  (add-hook 'ediff-load-hook 'my/turn-off-scroll-bars)
  (add-hook 'ediff-mode-hook 'my/turn-off-scroll-bars)
  (add-hook 'ediff-suspend-hook 'my/turn-on-scroll-bars)
  (add-hook 'ediff-quit-hook 'my/turn-on-scroll-bars)
#+END_SRC

*** gitignore major mode
:PROPERTIES:
:ID:       94749d5b-1577-4932-af4f-d6e786056cf6
:END:

Major mode for editing gitignore files

#+BEGIN_SRC emacs-lisp
(use-package gitignore-mode :defer t )
(use-package gitconfig-mode :defer t )
#+END_SRC

*** git-timemachine
:PROPERTIES:
:ID:       938e9345-2a8b-4a70-b41e-b4a0c1186f7c
:END:
Though see also vc-annotate's "n" & "p" bindings
this package is soooo cool! you execute git-timemachine, you can then press p and n to go to the
previous and next verions. w copies the git hash of the current buffer, and q quits the buffer
#+BEGIN_SRC emacs-lisp
(use-package git-timemachine  :defer t)
#+END_SRC

*** git messenger
   :PROPERTIES:
   :ID:       372e6c67-514b-4e1e-8d25-9be2a30da22f
   :END:
Type this command on any line of a repo.  It'll tell you the commit when it appeared.
#+BEGIN_SRC emacs-lisp
(use-package git-messenger :defer t )
(global-set-key (kbd "C-x v p") #'git-messenger:popup-message)
#+END_SRC
;; since I'm using helm-mode, magit will use helm-completion for stuff! awesome!
** vc-mode
:PROPERTIES:
:ID:       642acc9e-8521-4bfe-8fd0-6d30bc323e4d
:END:
 This shows you in the fringes of the buffer (this is the left column on the left side of your buffer)
 whick text in a buffer has not yet been committed.

 [[~/.config/emacs/images/vc-diff.png]]

 #+BEGIN_SRC emacs-lisp
   (use-package diff-hl :defer t)
   (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
   (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)
 #+END_SRC
** dired
  :PROPERTIES:
  :ID:       425e59a0-c254-44df-b50b-d008d5258df8
  :END:

Dired is the Emacs file manager.  It looks like this:

[[~/.config/emacs/images/dired.png]]

It lets you rename files, run massive search and replace commands, compress files, etc.

Enable async dired commands.

And also, do not open multiple dired buffers, as I traverse a directory tree.
#+BEGIN_SRC emacs-lisp
  (after-load 'dired
  ;;(autoload 'dired-async-mode "dired-async.el" nil t)
    (put 'dired-find-file-other-buffer 'disabled t)
    ;;(dired-async-mode 1)
)
#+END_SRC

alter net

*** Dired details
:PROPERTIES:
:ID:       3b1694dd-ea8d-4f8a-b24e-5d16f1cdd07a
:END:

http://whattheemacsd.com/setup-dired.el-01.html
I don't need dired to automatically show me all the details ie: all the permissions and stuff
If I do want the details I can use ")" to show them and "(" to hide them again
#+BEGIN_SRC emacs-lisp  :tangle no
(use-package dired-details
  :config
  (setq-default dired-details-hidden-string "--- ")
  :defer t
)
#+END_SRC

*** dired
:PROPERTIES:
:ID:       b316742c-74f3-4393-82a1-c51860523e7c
:END:

#+BEGIN_SRC emacs-lisp
  (use-package dired
    ;; before loading dired, set these variables
    :init
    (load "dired-x")  ;; for dired-omit-mode
    (setq-default diredp-hide-details-initially-flag nil
                  dired-dwim-target t
                  ;;omit boring auto save files in dired views
                  dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$")
    ;;:config ;; after loading dired, do this stuff
    ;;(load "dired-x")
    ;;(setq wdired-allow-to-change-permissions t)
    :bind
    (:map dired-mode-map
          ("/" . helm-swoop)
          ([mouse2] . dired-find-file)
          ("e" . 'ora-ediff-files)
          ))

  (with-eval-after-load 'dired
    (add-hook 'dired-mode-hook 'dired-omit-mode)
    ;; this doesn't seem to work :
    (add-hook 'dired-mode-hook 'all-the-icons-dired-mode))
#+END_SRC

**** Ediff two marked files
:PROPERTIES:
:ID:       05dc8ce4-1d7e-411e-be77-924078a92ed0
:END:

#+BEGIN_SRC emacs-lisp
(defun ora-ediff-files ()
  (interactive)
  (let ((files (dired-get-marked-files))
        (wnd (current-window-configuration)))
    (if (<= (length files) 2)
        (let ((file1 (car files))
              (file2 (if (cdr files)
                         (cadr files)
                       (read-file-name
                        "file: "
                        (dired-dwim-target-directory)))))
          (if (file-newer-than-file-p file1 file2)
              (ediff-files file2 file1)
            (ediff-files file1 file2))
          (add-hook 'ediff-after-quit-hook-internal
                    (lambda ()
                      (setq ediff-after-quit-hook-internal nil)
                      (set-window-configuration wnd))))
      (error "no more than 2 files should be marked"))))

#+END_SRC
*** COMMENT dired things I don't use, but would like to
**** dired-icon
https://www.topbug.net/dired-icon/
#+BEGIN_SRC emacs-lisp
(use-package dired-icon )
(add-hook 'dired-mode-hook 'dired-icon-mode)
#+END_SRC

**** dired rsync
But it doesn't seem to work ???
I found this code snippet here:
https://truongtx.me/2013/04/02/emacs-async-file-copying-in-dired-using-rsync
#+BEGIN_SRC emacs-lisp
(defun tmtxt/dired-rsync (dest)
  (interactive
   ;; offer dwim target as the suggestion
   (list (expand-file-name (read-file-name "Rsync to:" (dired-dwim-target-directory)))))
  ;; store all selected files into "files" list
  (let ((files (dired-get-marked-files nil current-prefix-arg)))
	;; the rsync command
	(setq tmtxt/rsync-command "rsync -arvz --progress ")
	;; add all selected file names as arguments to the rsync command
    (dolist (file files)
	  (setq tmtxt/rsync-command
			(concat tmtxt/rsync-command
					(shell-quote-argument file)
					" ")))
	;; append the destination
	(setq tmtxt/rsync-command
		  (concat tmtxt/rsync-command
				  (shell-quote-argument dest)))
	;; run the async shell command
	(async-shell-command tmtxt/rsync-command "*rsync*")
	;; finally, switch to that window
	(other-window 1)))
;;; bind it to C-c C-r
(define-key dired-mode-map (kbd "C-c C-r") 'tmtxt/dired-rsync)
#+END_SRC
**** Dired sort
:PROPERTIES:
:ID:       2adfc507-73e7-46c5-9cea-35d84a0917fa
:END:
press "S" in a dired buffer to see dired sort in action
#+BEGIN_SRC emacs-lisp
;;(use-package dired-sort )
#+END_SRC
**** Dired+
:PROPERTIES:
:ID:       0460cdf9-b11d-4411-82cc-9aaf74d24621
:END:
#+BEGIN_SRC emacs-lisp
;;(use-package dired+  :defer t)
#+END_SRC
** css
:PROPERTIES:
:ID:       b88f1e6b-66f1-4209-b41e-19a06357db1c
:END:
*** rainbox mode
:PROPERTIES:
:ID:       7dae135a-17c8-4fea-943e-ba71d94fcb20
:END:
Colourise CSS colour literals

[[~/.config/emacs/images/css-colorize.png]]
#+BEGIN_SRC emacs-lisp
  (use-package rainbow-mode :defer t)
  (dolist (hook '(css-mode-hook html-mode-hook sass-mode-hook))
    (add-hook hook 'rainbow-mode))
#+END_SRC

*** SASS and SCSS
:PROPERTIES:
:ID:       edd1aa67-f551-452f-8644-1e73d7645ce9
:END:
#+BEGIN_SRC emacs-lisp
  (use-package sass-mode  :defer t)
  (use-package scss-mode  :defer t
    :config
    (setq-default scss-compile-at-save t)
    (setq scss-sass-command "/home/joshua/.guix-profile/bin/sassc"))

#+END_SRC

#+RESULTS:
: t

Create a after save command to compile scss files:

#+BEGIN_SRC emacs-lisp
  (defun my/sassc-minify-function ()
    "Minifying sassc files."
    (interactive)
    (when (eq major-mode 'scss-mode)
      ;; compile scss into css
      (progn
        (async-shell-command
         (concat  "sassc " (buffer-file-name) " "
                  (s-replace ".scss" ".css" buffer-file-name)) "*sassc compilation buffer*")
        ;; minimize the css into .min.css
        (async-shell-command
         (concat  "sassc -t compressed " (buffer-file-name) " "
                  (s-replace ".scss" ".min.css" buffer-file-name))
         "*sassc compression compilation buffer*"))))

  (add-hook 'scss-mode-hook '(lambda ()
                               (add-hook 'after-save-hook 'my/sassc-minify-function nil t)))

  (add-to-list 'display-buffer-alist (cons "\\\*sassc compilation buffer\\\*" (cons #'display-buffer-no-window nil)))
  (add-to-list 'display-buffer-alist (cons "\\\*sassc compression compilation buffer\\\*" (cons #'display-buffer-no-window nil)))


#+END_SRC

*** COMMENT LESS
#+BEGIN_SRC emacs-lisp
(use-package less-css-mode )
;; I don't think I've ever used skewer-mode.
;; (when (featurep 'js2-mode)
;;   (use-package skewer-less))
#+END_SRC

*** Use eldoc for syntax hints
   :PROPERTIES:
   :ID:       2586b70f-d7c5-475a-bb56-2236aa453dae
   :END:
#+BEGIN_SRC emacs-lisp
  (use-package css-eldoc  :defer t)

  ;;(autoload 'turn-on-css-eldoc "css-eldoc")
  (add-hook 'css-mode-hook 'css-eldoc-enable)
#+END_SRC

*** emmet mode
   :PROPERTIES:
   :ID:       2c0894d7-393a-45f2-a84c-c56acb03f837
   :END:
You should read more about css abbreviations with emmet mode!
https://github.com/smihica/emmet-mode#css-abbreviations
#+BEGIN_SRC emacs-lisp
(add-hook 'css-mode-hook 'emmet-mode) ;; enable Emmet's css abbreviation.
#+END_SRC
** jabber
:PROPERTIES:
:ID:       b0f1726b-83db-48b9-84e2-d866df1e68bf
:END:
I can use XMPP (previously knows as jabber) inside emacs!!! Awesome!!!

#+BEGIN_SRC emacs-lisp

  (use-package jabber
    :defer t
    :config
    (defalias 'my-jabber-connect-all 'jabber-connect-all)
    ;;(use-package helm)
    :init
    (setq jabber-account-list '(("jbranso@dismail.de"))
          jabber-history-enabled t
          jabber-history-muc-enabled t))

  (when my-onlinep
    (progn
      (add-hook 'emacs-startup-hook 'jabber-connect-all)
      ;; enable spell checking for jabber.
      (add-hook 'jabber-chat-mode-hook 'flyspell-mode)))
#+END_SRC


Connecting to Jabber
==============

Now, type 'C-x C-j C-c' and enter your JID and password.  If you
successfully connect, jabber.el will download your roster and display it
in a buffer called '*-jabber-roster-*'.

The default command to read the next unread jabber message is really silly.  Let's change that.

#+BEGIN_SRC emacs-lisp :tangle no
(global-set-key (kbd "C-x C-j u") 'jabber-activity-switch-to)
(global-set-key (kbd "C-x C-j C-u") 'jabber-activity-switch-to)
#+END_SRC

** ledger
:PROPERTIES:
:ID:       ddcf601b-75ac-46ce-ab16-c442158afdf6
:END:
#+BEGIN_SRC emacs-lisp
  (use-package ledger-mode
    :mode
    ("\\.ledger?\\'" . ledger-mode))

#+END_SRC
** message and mail mode
   :PROPERTIES:
   :ID:       d5149a56-9461-46f6-909b-cbacc0ef5b52
   :END:

   Automatically fill in the paragraph that you are typing.

   #+BEGIN_SRC emacs-lisp
     (add-hook 'message-mode-hook 'auto-fill-mode)
     (add-hook 'mail-mode-hook 'auto-fill-mode)
   #+END_SRC
* hideshow
:PROPERTIES:
:ID:       8a07b2dc-1457-4535-a479-00d5a14f0fef
:END:
Emacs minor mode to hide or display structured section of code.  VERY COOL!

Try to get hs-minor-mode to work with JSON, because that would be super cool!

#+BEGIN_SRC emacs-lisp
  (use-package hideshow
    :bind (("C-x C-h" . hs-toggle-hiding)
           ("C-x C-S-+" . hs-show-all))
    :init
    (add-hook #'json-mode-hook #'hs-minor-mode)
    (add-hook 'c-mode-hook 'hs-minor-mode)
    :config
    (setq hs-special-modes-alist
          (mapcar 'purecopy
                  '((c-mode "{" "}" "/[*/]" nil nil)
                    (c++-mode "{" "}" "/[*/]" nil nil)
                    (java-mode "{" "}" "/[*/]" nil nil)
                    (js-mode "{" "}" "/[*/]" nil)
                    (json-mode "{" "}" "/[*/]" nil)
                    (javascript-mode  "{" "}" "/[*/]" nil)))))
#+END_SRC
* company mode
** download company mode
:PROPERTIES:
:ID:       8ed6b2f0-bcf6-4bcb-9960-8128383be671
:END:

Company mode has bound tab to complete the common part between two snippets.  I'd rather have tab mean select the first snippet. I'm getting some of the code from this gist: https://gist.github.com/nonsequitur/265010

#+BEGIN_SRC emacs-lisp
  (use-package company
    :defer t
    :config
    (setq company-idle-delay .2)
    (define-key company-active-map "\C-n" #'company-select-next)
    (define-key company-active-map "\C-p" #'company-select-previous)
    (define-key company-active-map (kbd "<tab>") #'company-complete-selection)
    :diminish (company-mode))

    (add-hook 'prog-mode-hook 'global-company-mode)
  #+END_SRC

** show yasnippets in company mode
:PROPERTIES:
:ID:       f9dba9a6-e011-48cb-8a14-6a365fe78c1c
:END:

#+BEGIN_SRC emacs-lisp
(dolist (hook '(prog-mode-hook
                text-mode-hook
                org-mode-hook))
  (add-hook hook
            (lambda ()
              (set (make-local-variable 'company-backends)
                   '((company-dabbrev-code company-yasnippet))))))
#+END_SRC
* flycheck
:PROPERTIES:
:ID:       f6a02ab5-420e-4dc8-a8c2-7ae8e1e0acce
:END:

This is not necessary, because spaceline theme provides this functionality.

Show cute flycheck error-images in the modeline.

#+BEGIN_SRC emacs-lisp :tangle no
   (use-package flycheck-status-emoji  :defer t)
     ; :config (set-fontset-font t nil "Symbola")
#+END_SRC

 Color the mode line based on how the errors flycheck finds or doesn't find

#+BEGIN_SRC emacs-lisp :tangle no
(use-package flycheck-color-mode-line  :defer t)
#+END_SRC

Show all errors in a popup.
#+BEGIN_SRC emacs-lisp
  (use-package flycheck
    :config
    ;;(flycheck-pos-tip-mode)
    ;; enable flychek for programming modes
    :defer t)
  #+END_SRC

 Enable flycheck for all programming modes.

 #+BEGIN_SRC emacs-lisp
  (add-hook 'prog-mode-hook 'flycheck-mode)
  #+END_SRC

* helm
:PROPERTIES:
:ID:       a077141f-fed4-4e16-92fb-5c31ae849737
:END:

By default helm-do-git-grep, searching the current directory.  C-u helm-do-git-grep searches the entire project.

Helm mode is an incremental completion framework, that is much better than ido-mode.
[[~/.config/emacs/images/helm-buffers-list.gif]]

Before we load any helm things, need to load helm-flx so it uses flx instead of helm's fuzzy matching.

We can autoload helm functionality with the bind-keymap.

Here is the maintainer's helm configuration file:
https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/init-helm.el

More info about helm:
https://emacs-helm.github.io/helm/#getting-started

#+BEGIN_SRC emacs-lisp
  (use-package helm
    :bind-keymap
    ("C-c h" . helm-command-map)
    :config
    ;; emacs 27 and helm-mode have a memory leak.  The below line
    ;; fixes the memory leak.
    (setq helm-ff-keep-cached-candidates nil)
    (require 'helm-config)
    (helm-mode 1)
    (defalias 'helm-browse-kill-ring 'helm-show-kill-ring)
    (use-package helm-swoop)
    (use-package helm-flx
      ;; TODO what is this?

      :config (helm-flx-mode +1))

    :bind
    (("M-x" . helm-M-x)
     ("C-x C-f" . helm-find-files)
     :map helm-find-files-map
     ("C-h" . helm-select-action)
     ("TAB" . helm-execute-persistent-action)))

#+END_SRC

According to the github repo this next line is all that I need to install helm

#+BEGIN_SRC emacs-lisp
  (defun my/config-helm-function ()
    "This just sets up helm."
    (interactive)
    ;;(define-key helm-find-files-map (kbd "<tab>") 'helm-ff-RET)
    ;;(define-key helm-map (kbd "<backtab>") 'helm-select-action)
    ;;(global-set-key (kbd "C-c h s") 'helm-do-ag)
    (global-set-key (kbd "C-x C-f") 'helm-find-files)
    (global-set-key (kbd "C-x r b") 'helm-bookmarks))

    (add-hook 'after-init-hook 'my/config-helm-function)
#+END_SRC

I've installed helm-ag, which might be cool.

#+BEGIN_SRC emacs-lisp
(setq
 ;;don't let helm swoop guess what you want to search... It is normally wrong and annoying.
 helm-swoop-pre-input-function #'(lambda () (interactive))
 ;; tell helm to use recentf-list to look for files instead of file-name-history
 helm-ff-file-name-history-use-recentf t
 ;; let helm show 2000 files in helm-find-files
 ;; since I let recent f store 2000 files
 helm-ff-history-max-length 2000
 ;; I've set helm's prefix key in init-editing utils
 ;; don't let helm index weird output files from converting .tex files to pdf for example
 helm-ff-skip-boring-files t
 ;; enable fuzzy mating in M-x
 helm-M-x-fuzzy-match t
 helm-recentf-fuzzy-match t
 helm-apropos-fuzzy-match t
;;the more of these sources that I have, the slower helm will be
 helm-for-files-preferred-list '(
                                 helm-source-buffers-list
                                 helm-source-recentf
                                 helm-source-bookmarks
                                 helm-source-file-cache
                                 helm-source-files-in-current-dir
                                 ;;helm-source-locate
                                 ;;helm-source-projectile-files-in-all-projects-list
                                 ;;helm-source-findutils
                                 ;;helm-source-files-in-all-dired
                                 ))
#+END_SRC

** helm-system packages
:PROPERTIES:
:ID:       017fcb2c-ec71-4a34-838b-a4517b182f59
:END:
Helm system packages is a front-end to install packages with pacman!

https://github.com/emacs-helm/helm-system-packages

#+BEGIN_SRC emacs-lisp
(use-package helm-system-packages  :defer t)
#+END_SRC

* TODO eww

<jab> I suppose the only thing that I really want to tweak about shr mode is
      to set it to have body {padding-left:20px;}
<acdw> righ!? lol
<jab> acdw: That would be pretty sweet!
<acdw> i have a little reading mode in my config that enables olivetti mode,
       which kind of does that
<jab> olivetti mode...I'll look that up  [15:14]
<acdw> https://tildegit.org/acdw/emacs/src/branch/main/lisp/acdw.el#L518
<acdw> is my thing
<jab> acdw:  thanks!  I might really like that for org-mode too!  maybe...
                                                                        [15:15]
<wgreenhouse> there's olivetti and writeroom, similar but different

* prett-ifying things
** spaceline
:PROPERTIES:
:ID:       20de3b77-52eb-4e56-8c5b-c309e9211bd0
:END:

Space line is not allowing my jabber notifications to come through...

#+BEGIN_SRC emacs-lisp
(use-package spaceline)
#+END_SRC

#+BEGIN_SRC emacs-lisp
  (use-package spaceline-all-the-icons

    :config
    (setq spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
    (spaceline-all-the-icons-theme))
#+END_SRC

Adding a custom spaceline-all-the-icons segment:

(spaceline-all-the-icons-theme 'my/jabber "Hello" 'etc)

Ok how do I turn off this new custom segment?

(spaceline-all-the-icons--turn-off 'my/jabber)

** COMMENT smart mode-line
:PROPERTIES:
:ID:       234a4918-8947-4e1c-85ed-77c0501fdcfb
:END:

Make the mode line look prettier.  I'd like to use spaceline eventually, but oh well.

Smart mode line is causing some issues with tramp and loading buffers.

The function that is causing the trouble is:

sml/*if-necessary

#+BEGIN_SRC emacs-lisp
(use-package smart-mode-line-powerline-theme  :defer t)
#+END_SRC

Smart mode line apparently is more active and works w/ just about anything

#+BEGIN_SRC emacs-lisp :toggle no
  (use-package smart-mode-line
    :init
    (setq sml/theme 'powerline ;; or automatic
    ;; automatic will try to automatically configure things
          ;; emacs keeps prompting me to run the smart-mode-line-theme.  This is a word around that I found on github
          sml/no-confirm-load-theme t
          powerline-arrow-shape 'curve
          powerline-default-separator-dir '(right . left)
          sml/mode-width 0
          ;; this makes sure that the mode line doesn't go off the screen
          sml/name-width 40
          rm-whitelist nil
          rm-blacklist '(" Helm" " Fly" " Wrap" " Abbrev" " Ind"))
(sml/setup))

#+END_SRC

/ssh:joshua@richardrahl:/etc/nginx/sites-available/laundrysucks.io  is a long file name.  Let's change that:

#+BEGIN_SRC emacs-lisp :tangle no
(add-to-list 'sml/replacer-regexp-list '("^/ssh:joshua@richardrahl:/etc/nginx/" ":rahl/nginx:") t)
#+END_SRC

Customizing the smart-mode-line theme!  I can customize sml.  I just need to tweak the variable sml/theme, and then call sml/setup.


  (custom-set-faces
   ;; custom-set-faces was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
   '(default ((t (:foreground "#DCDCCC" :background "#3F3F3F"))))
   '(sml/charging ((((class color) (min-colors 89)) (:foreground "#BFEBBF"))))
   '(sml/client ((t (:inherit sml/prefix :background "black"))))
   '(sml/filename ((t (:inherit sml/global :background "#383838" :foreground "#6ca0a3" :weight bold))))
   '(sml/folder ((t (:inherit sml/global :background "#383838" :foreground "Black" :weight normal))))
   '(sml/global ((t (:background "black" :foreground "#6f8f6f" :inverse-video nil :weight bold))))
   '(sml/minor-modes ((t (:inherit sml/folder :foreground "#8fb28f" :weight ultra-bold))))
   '(sml/modes ((t (:inherit sml/global :background "#6f8f6f" :foreground "#2b2b2b" :weight bold))))
   '(sml/name-filling ((t (:inherit sml/prefix :background "#6f8f6f" :weight normal))))
   '(sml/position-percentage ((t (:inherit sml/prefix :background "#6f8f6f" :foreground "#2b2b2b" :weight normal))))
   '(sml/prefix ((t (:inherit sml/global :background "grey17" :foreground "#8fb28f"))))
   '(sml/process ((t (:inherit sml/prefix :background "#6f8f6f" :weight bold)))))

** COMMENT sunrise is a alternative to flotilla
:PROPERTIES:
:ID:       0fbd3e1d-68cd-4da9-a6c6-f6e8a097332f
:END:
    #+BEGIN_SRC emacs-lisp
;;    (require 'init-sunrise)
    #+END_SRC

** COMMENT testing out ivy
  (use-package ivy
:config
(setq ivy-height 30))

(use-package counsel )

** COMMENT A register hydra
(reqgister)

;; Ieed to use (set-register register value)

"
regist is this:
Alisments (NAME . CONTENTS), one for each Emacs register.
NAMEaracter (a number).  CONTENTS is a string, number, marker, list
or areturned by `registerv-make'.

So m to register command must transform my NAME char into an ASCII number.  fun.
"

(defmber-to-register (number register)
  (ive "n number: \nMregister: ")
  ;;to-register number register)
  ;;r to use
  (ster register number))

;; g is getting soo annoying and it's not working at all
;;(pister-alist)

(defsert-register (register)
  (ive "Mregister: ")
  (pister)
  (igister register))

(defcrement-register ())   (get-register "r")

(defdra-register (:color pink :hint nil)
  "
^Sto                ^Insert^                       ^Increase^
^^^^----------------------------------------------------------------
_n_uregister        _i_nsert number register       _I_ncrease the register
C-u  C-x r n R
insebers left       C-x r i R                      C-u number C-x r + r
  ofle              Insert _t_ext to register
  C-                C-x r s R
"
  ;;
  ("mber-to-register :exit t)
  ("ngle-number-lines :exit t)

  ;;
  ("sert-register :exit t)          ; Show (expand) everything
  ("to-register :exit t)          ; Show (expand) everything

  ;;e
  ("crement-register  :exit t)    ; Hide everything but the top-level headings

  ("leave"))


;; I set this hydra to a keybinding.  So I don't have to remember all of the keybindings
(glokey (kbd "C-c C-r") 'hydra-register/body)
;; aother modes try to set C-c C-r to a keybinding.  I am overriding them.
(witfter-load 'org
  (dy org-mode-map (kbd "C-c C-r") 'hydra-register/body))
(witfter-load 'web-mode
  (dy web-mode-map (kbd "C-c C-r") 'hydra-register/body))
(witfter-load 'php-mode
  (dy php-mode-map (kbd "C-c C-r") 'hydra-register/body))
*** COMMENT rust
http://emacsist.com/10425
#+BEGIN_SRC emacs-lisp
;;(use-package rust )
#+END_SRC
*** COMMENT autocorrect
:PROPERTIES:
:ID:       ed63d49c-50d4-468a-9df2-8b578a823e90
:END:

My hacky Emacs autocorrect functionality, is not the best.  It changes things that I don't want changed all the time, etc.

Until it's better, I don't want to use it

#+BEGIN_SRC emacs-lisp
;; (org-babel-load-file "/home/joshua/programming/emacs/autocorrect/autocorrect.org" )
#+END_SRC

*** abbrev-mode
:PROPERTIES:
:ID:       6c870f0d-d805-4e4c-b6d6-09233397e444
:END:
Add abbrev-mode to text modes and program modes to turn on autocorrect like functionality.
#+BEGIN_SRC emacs-lisp
(dolist (hook '(org-mode-hook
                prog-mode-hook
                text-mode-hook))
  (add-hook hook (lambda ()
                   (abbrev-mode 1)
                   (diminish 'abbrev-mode))))

#+END_SRC

*** logging the commands I use often.
    this will be cool to monitor my commands.
    But I have to initialize it...It will not record commands by default.
    I don't really use this functionality.  I never see what commands I'm using.  So I'll ignore it for now.
    (use-package mwe-log-commands)
    (me:log-keyboard-commands)
*** python mode

    (require 'init-python-mode)

*** github

    (require 'init-gitgub)

*** I don't know what this is
    http://alexott.net/en/writings/emacs-vcs/EmacsDarcs.html
    (require 'init-darcs)
*** stackexchange in emacs
    I also hardly ever use this sx package, which is an amazing package!
    searching stack exchange via emacs!  C-c S
    (use-package sx )
*** downcase words like THe and BEautiful
     This is probably how I can embed yasnippets into various modes

    (require 'init-dubcaps)

*** I found this on the internet, but don't use it

     reduce the frequency of garbage collection by making it happen on
     each 50MB of allocated data (the default is on every 0.76MB)
     this might help improve performance
    ;;(setq gc-cons-threshold 50000000)

*** bookmark
:PROPERTIES:
:ID:       7f780f9c-3c32-4ac7-b733-885d3651b0e7
:END:

(require 'bookmark)
(defhydra hydra-bookmark (:color pink :hint nil)
  "
^Edit^                   ^Jump^                    ^Set^
^^^^^^------------------------------------------------------
_e_: edit bookmarks     _j_ump to bookmark         _s_: set bookmark
_r_: rename             _J_ump to gnus bookmark    _S_: set a gnus bookmark
"
  ;; Edit
  ("e" edit-bookmarks :exit t)                ; Up
  ("r" helm-bookmark-rename :exit t)                ; Up

  ;; Jump
  ("j" bookmark-jump :exit t)          ; Show (expand) everything
  ("J" gnus-bookmark-jump :exit t)          ; Show (expand) everything

  ;; Set
  ("s" bookmark-set :exit t)    ; Hide everything but the top-level headings
  ("S" gnus-bookmark-set :exit t)    ; Hide everything but the top-level headings

  ("z" nil "leave"))

;; I want to set this hydra to a keybinding.  So I don't have to remember all of the keybindings
(global-set-key (kbd "C-c C-b") 'hydra-bookmark/body)
;; a ton of other modes try to set C-c C-b to a keybinding.  I am overriding them.
(with-eval-after-load 'org
  (define-key org-mode-map (kbd "C-c C-b") 'hydra-bookmark/body))
(with-eval-after-load 'web-mode
  (define-key web-mode-map (kbd "C-c C-b") 'hydra-bookmark/body))
(with-eval-after-load 'php-mode
(define-key php-mode-map (kbd "C-c C-b") 'hydra-bookmark/body))

** COMMENT eldoc
Show eldoc popups in pos-tips.  I got the idea [[https://www.topbug.net/blog/2016/11/03/emacs-display-function-or-variable-information-near-point-cursor/][here]].
   (defun my-eldoc-display-message (format-string &rest args)
    "Display eldoc message near point."
    (when format-string
      (pos-tip-show (apply 'format format-string args))))
  (setq eldoc-message-function #'my-eldoc-display-message)
** COMMENT (require 'init-term)
** page break line modes
:PROPERTIES:
:ID:       ce614852-2e6c-4c4d-9011-a478bc5e96f9
:END:
This turn ^L into nice long lines.

This package turns "^L" into a delimiting line character.  It is easy to insert such a character.  Just put point over a char, press "r" in normal mode (replace), then press C-l.  That command replaces the character with "^L".

To see what this looks like, then open the snippet below with "C-c '".
#+BEGIN_SRC emacs-lisp
      
#+END_SRC

#+BEGIN_SRC emacs-lisp
  (use-package page-break-lines
    :diminish page-break-lines-mode
    :config (add-hook 'prog-mode-hook 'page-break-lines-mode))
#+END_SRC

DO NOT enable page break lines mode with org-mode.  Org-mode freaks out when it sees "^L"!  Org-mode will turn "^L" into 50+ lines.  It looks really wrong.

** Wttrin
:PROPERTIES:
:ID:       764c4eb4-fc8f-497d-89af-ad8db03e0f75
:END:
Wtrin is a small emacs package that gets you the local weather forcast.  It pulls from http://wttr.in/.

[[~/.config/emacs/images/weather.png]]

#+BEGIN_SRC emacs-lisp
(use-package wttrin

  :commands (wttrin)
  :init
  (setq wttrin-default-cities
  '("West Lafayette"))
  (setq wttrin-default-accept-language '("Accept-Language" . "en-US")))
#+END_SRC

#+BEGIN_SRC emacs-lisp
  (defun weather ()
    "Show the local weather via wttrin"
    (interactive)
    (wttrin))
#+END_SRC
** which-key
:PROPERTIES:
:ID:       6dd77f41-e39f-4c24-a2af-f46a6bd59398
:END:
This package is like guide-key, but better.  As you start to type a keychord, but then forget how to finish it,
which-key will bring up a small buffer to show you possible completions.

#+CAPTION: Which key displays the current major mode's keybindings
#+NAME:   fig:which-key
[[~/.config/emacs/images/which-key.png]]

#+BEGIN_SRC emacs-lisp
  (use-package which-key
    :config
    ;; max height of which-key frame: number of lines (an integer)
    (setq which-key-frame-max-height 60)
    (which-key-mode 1))
#+END_SRC

** global-prettify-symbols-mode
:PROPERTIES:
:ID:       9aa51c7a-fd2c-4984-88d7-f54f702a3a1d
:END:
Make "-->" look like --> and ">=" look >= cool utf-8 characters.

Add some more characters cool characters.  You can get some cool ideas from [[https://ekaschalk.github.io/post/prettify-mode/][prettymode]]
The characters end up looking like:

[[~/.config/emacs/images/pretty-mode.png]]


#+BEGIN_SRC emacs-lisp
(defun my/add-extra-prettify-symbols ()
    (global-prettify-symbols-mode 1)
    (mapc (lambda (pair) (push pair prettify-symbols-alist))
          '(
            (">=" . ?≥)
            ("<=" . ?≤)
            ("\\geq" . ?≥)
            ("\\leq" . ?≤)
            ("\\neg" . ?¬)
            ("\\rightarrow" . ?→)
            ("\\leftarrow" . ?←)
            ("\\infty" . ?∞)
            ("-->" . ?→)
            ("<--" . ?←)
            ("\\exists" . ?∃)
            ("\\nexists" . ?∄)
            ("\\forall" . ?∀)
            ("\\or" . ?∨)
            ("\\and" . ?∧)
            (":)" . ?☺)
            ("):" . ?☹)
            (":D" . ?☺)
            ("\\checkmark" . ?✓)
            ("\\check" . ?✓)
            ("1/4" . ?¼)
            ("1/2" . ?½)
            ("3/4" . ?¾)
            ("1/7" . ?⅐)
            ;; ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞
            ("ae" . ?æ)
            ("^_^" . ?☻)
            ("function" .?ϝ)
            )))
  (add-hook 'after-init-hook 'my/add-extra-prettify-symbols)
  ;;(add-hook 'prog-mode-hook 'my/add-extra-prettify-symbols)
#+END_SRC

** all the icons
:PROPERTIES:
:ID:       19d20513-a02a-42fc-91b2-76f7c32df062
:END:
You can learn more about [[https://github.com/domtronn/all-the-icons.el][all the icons]] here.

[[~/.config/emacs/images/all-the-icons.png]]

You need the icons for this to work dummy.

#+BEGIN_SRC emacs-lisp
(use-package all-the-icons :defer t)
(use-package all-the-icons-dired  :defer)
#+END_SRC
* mu4e
:PROPERTIES:
:ID:       1d00e931-ca57-45ae-ae30-1e5d3a99c503
:END:
#+BEGIN_SRC emacs-lisp
(require 'mu4e)
;;(use-package mu4e-alert  :defer t)
#+END_SRC

Tell mu where various folders are:

#+BEGIN_SRC emacs-lisp
  (setq
   mu4e-maildir       "~/.mail/dismail.de"   ;; top-level Maildir
   mu4e-sent-folder   "/Sent"       ;; folder for sent messages
   mu4e-drafts-folder "/Drafts"     ;; unfinished messages
   mu4e-trash-folder  "/Trash"      ;; trashed messages
   mu4e-refile-folder "/Archive")   ;; saved messages

#+END_SRC

#+BEGIN_SRC emacs-lisp
  ;; attempt to show images when viewing messages
  (setq mu4e-view-show-images t)

  (setq mu4e-get-mail-command nil
        mu4e-update-interval 301)
#+END_SRC
* misc
** debbugs
:PROPERTIES:
:ID:       003c766a-9684-41b3-93a4-0deea880fffd
:END:

  If I want to look at Emacs bugs, I debbugs is useful for this.

  #+BEGIN_SRC emacs-lisp
  (use-package debbugs  :defer t)
  #+END_SRC

** z-present
:PROPERTIES:
:ID:       ebfd37dd-dc32-4c0e-8b9a-9074e37740dc
:END:

Slides inside Emacs

#+BEGIN_SRC emacs-lisp
(use-package zpresent  :defer t)
#+END_SRC

Create an org-file and M-x zpresent turns the file into a presentation.  "n" is for next slide and "p" is for previous slide.

#+BEGIN_SRC org
  ,* First Slide
  Opening paragraph
  ,** Sub title 1
  Some more information on the first slide
  ,** sub title 2
  ,* Second Slide
  Opening paragraph
  ,** sub title 1
  More info
  ,** sub title 2
  Lots more info.
#+END_SRC

** better shell remote open
:PROPERTIES:
:ID:       0a0f0129-5e8f-40e7-a2fc-ae3c9b7f6622
:END:
#+BEGIN_SRC emacs-lisp
(use-package better-shell  :defer t)
#+END_SRC

better-shell-remote-open

This command is actually quite cool:  Try out better-shell-remote-open RET USERNAME@HOST RET PASSWORD RET

** pdf-tools
:PROPERTIES:
:ID:       f2e6b596-c709-4934-8fec-85bedf3c7468
:END:

Pdf tools is a better pdf viewer than the default DocView.

#+BEGIN_SRC emacs-lisp
(use-package pdf-tools
  :mode ("\\.pdf\\'" . pdf-view-mode)
  )

;;(pdf-tools-install)
#+END_SRC

** smart comment
   :PROPERTIES:
   :ID:       a5a5f993-e0a8-48c5-b80f-ccab9781591e
   :END:

   With point in the or beginning middle of the line comment out the whole line
   with point at the end of the line, add a comment to the left of the line
   with a region marked, marked the region for delition with "C-u C-c"
   delete the marked regions and lines with "C-u C-u C-c"
   #+BEGIN_SRC emacs-lisp
   (use-package smart-comment

       :bind ("C-c ;" . smart-comment)
       :config
       (with-eval-after-load 'org
         (local-unset-key "C-c ;")))
   #+END_SRC
** suggest
:PROPERTIES:
:ID:       93090d59-9fb2-43ca-aff8-f9a3f58a27dd
:END:
This is a program that lets suggests valid elisp functions to use. It is SO cool!

[[~/.config/emacs/images/suggest.png]]


You can read more [[http://www.wilfred.me.uk/blog/2016/07/30/example-driven-development/][here]].

#+BEGIN_SRC emacs-lisp
(use-package suggest  :defer t)
#+END_SRC
** eglot The MS language server protocol
:PROPERTIES:
:ID:       3293f036-9762-4b1f-8658-26c4eee59269
:END:

#+BEGIN_SRC emacs-lisp
(use-package eglot  :defer t)
#+END_SRC
** emacs can play music and stream it! (when streaming works)
:PROPERTIES:
:ID:       0d7835d6-b2b4-403a-8238-19781c899328
:END:
    #+BEGIN_SRC emacs-lisp
      (use-package emms
        :defer t
        :config
        (require 'emms-setup)
        (emms-all)
        (emms-default-players)
     (setq emms-source-file-default-directory "~/music/Ed Sheeran - +/"))
    #+END_SRC
** restclient
:PROPERTIES:
:ID:       4b48cf48-f613-4f29-ba05-912ad9ec08e3
:END:
https://github.com/pashky/restclient.el

I can get GETs and POSTs from websites now!  Very cool!

#+BEGIN_SRC emacs-lisp
  (use-package restclient
    :mode (("\\.http\\'" . restclient-mode)))
#+END_SRC

* COMMENT some things I don't use
** COMMENT dashboard
:PROPERTIES:
:ID:       89647a3c-06a2-4216-ba23-4a3254356132
:END:

Emacs dashboard displays a nice greating when you start the Emacs dashboard.
#+BEGIN_SRC emacs-lisp
  (use-package dashboard

    :config
    (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
    ;;(add-to-list 'dashboard-items '(agenda) t)
    (setq dashboard-items '((agenda . 5)
                            (recents  . 5)
                            (projects . 5)))
    (setq show-week-agenda-p t)
    (dashboard-setup-startup-hook))
#+END_SRC
** COMMENT elscreen

#+BEGIN_SRC emacs-lisp
  (use-package elscreen
    :config
                                          ;(setq elscreen-prefix-key [26])
    ;;(setq elscreen-prefix-key "C-c z")
    :bind (;;([<C-tab>] . elscreen-next)
           ((kbd "[<C-tab>]" . elscreen-next)))
    (elscreen-start))


#+END_SRC
** COMMENT Golden ratio mode
I need to use the other new package
:PROPERTIES:
:ID:       a56ac24d-7ddb-4b6c-8ad1-9b817e4a73fe
:END:
https://github.com/roman/golden-ratio.el
#+BEGIN_SRC emacs-lisp :tangle no
    (use-package golden-ratio
    :defer t

    ;;let's not use golden ratio on various modes
    :config (setq golden-ratio-exclude-modes
                    '( "sr-mode" "ediff-mode" "ediff-meta-mode" "ediff-set-merge-mode" "gnus-summary-mode"
                    "magit-status-mode" "magit-popup-mode" "org-export-stack-mode"))
                       (golden-ratio-mode)

                       :diminish golden-ratio-mode)
    (add-hook 'prog-mode-hook 'golden-ratio-mode)
  #+END_SRC

I had to find the source code for turning off golden-ratio-mode.  Because
~(golden-ratio-mode nil)~ does not turn off golden-ratio-mode.
#+BEGIN_SRC emacs-lisp
  (defun my-ediff-turn-off-golden-ratio ()
    "This function turns off golden ratio mode, when I
  enter ediff."
    (interactive)
    (remove-hook 'window-configuration-change-hook 'golden-ratio)
    (remove-hook 'post-command-hook 'golden-ratio--post-command-hook)
    (remove-hook 'mouse-leave-buffer-hook 'golden-ratio--mouse-leave-buffer-hook)
    ;; I'm not sure what these functions did, but I guess golden ratio doesn't need them anymore?
    ;;(ad-deactivate 'other-window)
    ;;(ad-deactivate 'pop-to-buffer)
)

#+END_SRC

Let's turn off golden-ratio-mode when I am using ediff, and turn it back on
when I quit ediff.

#+BEGIN_SRC emacs-lisp
  (add-hook 'ediff-mode-hook #'my-ediff-turn-off-golden-ratio)

  (add-hook 'ediff-quit-merge-hook #'golden-ratio)
#+END_SRC

** COMMENT linum Emacs now has a built in way of doing this
:PROPERTIES:
:ID:       6f74055f-5351-453f-90cf-491045428704
:END:
   display line numbers in the fringe on the left of the page.

   I'd love to globally enable linum mode, but it slows Emacs to a crawl on large org buffers.
   #+BEGIN_SRC emacs-lisp
     (dolist (hook '(
     c-mode-hook
     js2-mode-hook
     scss-mode-hook
     css-mode-hook
     php-mode-hook
     web-mode-hook
     emacs-lisp-mode-hook
     ))
       (progn
         (add-hook hook 'linum-mode)
         ))

         #+END_SRC

   I'd prefer to use nlinum mode, because it's faster.  BUT it also makes it that I cannot open a new Emacs frame.
#+BEGIN_SRC emacs-lisp
;; (use-package nlinum )

#+END_SRC
** COMMENT uniquify
:PROPERTIES:
:ID:       96509ae1-422f-4821-9939-6c5eae7d740e
:END:

Should I get rip of this?  Does my new modeline get rid of it?

 Nicer naming of buffers for files with identical names. Instead of Makefile<1> and Makefile<2>, it will be Makefile | tmp
 Makefile | lisp this file is part of gnus emacs.  I don't need to use use-package
 #+BEGIN_SRC emacs-lisp  :toggle no
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator " • ")
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*")
 #+END_SRC
** paradox
    Paradox adds some nice features to emacs install packages
    this sets up paradox to use my private token to access public repos.
    #+BEGIN_SRC emacs-lisp
    ;;(require 'init-paradox)
    #+END_SRC
** ebdb
:PROPERTIES:
:ID:       4780c04c-4d88-4983-8597-ff07d62c8a7f
:END:

This is a port of BBDB to EIEIO, which is emacs lisp's OO library.  It has a nice manual, and maybe someday I'll use it.

#+BEGIN_SRC emacs-lisp
  (use-package ebdb  :defer t
    :config
    (use-package company-ebdb ))
#+END_SRC
* provide this file
:PROPERTIES:
:ID:       de5dc789-d53e-4932-87fc-844370a9b796
:END:
#+BEGIN_SRC emacs-lisp
  (provide 'init-load-small-packages)
#+END_SRC
